angular.module('cartMod',[])
.controller('cartCtrl',['$scope','cart','selectService','total',function($scope,cart,selectService,total){
	// $scope.carData = JSON.parse(window.localStorage.cart);
	$scope.cartData = cart;
	$scope.price = 0;
	$scope.count = 0;
	$scope.total = total;
	$scope.abc = true;
	// for (var j in cart.dataCart) {
	// 		$scope.price = cart.dataCart[j].price;
	// 		$scope.count = cart.dataCart[j].num;
	// 		$scope.total += $scope.price*$scope.count;
	// }
	$scope.addFun = function(id,i){
		i.num ++;
		// $scope.total += parseFloat(i.price);
		total.fun();
	}
	$scope.delFun = function(id,i){
		i.num--;
		if (i.num<1) {
			$scope.cartData.delFun(id);
		}
		// $scope.total -= parseFloat(i.price);
		total.fun();
	}


	// 全选
	$scope.all = function(){
		selectService.selectAll(this.abc);
		console.log(this.abc);
		total.fun();
		
	}

	//单选
	$scope.danxuan = function(tag,price,num){
		// if (tag==true) {
		// 	$scope.total += price*num;
		// } else {
		// 	$scope.total -= price*num;
		// }
		// var _state = true;
		// for (var j in cart.dataCart) {
		// 	if (!cart.dataCart[j].status) {
		// 		_state = false;
		// 	} 
		// }
		// $scope.abc = _state;
		$scope.abc = selectService.danxuan();
		console.log(selectService.danxuan());
		total.fun();

	}


}])